package com.itheima.zuoye.zuoye4;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        try {
            FileOutputStream fos = new FileOutputStream("D:\\java-base-ws\\JavaAdvanceProject\\day12_IO_zifuji\\src\\com\\idheima\\IO\\akun.txt");
            int i = 1;
            while (true) {
                System.out.println("请输入第" + i + "个学生的姓名和年龄,学生信息之间使用逗号分隔(ok表示结束)");
                String info = sc.nextLine();
                //判断结束录入的条件
                if (info.equals("ok") && i > 3) {
                    break;
                }else if (info.equals("ok")) {
                    System.out.println("请输入至少三个学生信息");
                    continue;
                }
                //添加信息
                fos.write(info.getBytes());
                fos.write("\r\n".getBytes());
                //记录次数
                i++;
            }
            System.out.println("录入完毕");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
